package com.example.yucheng.service.impl;

import com.example.yucheng.domain.Warn;
import com.example.yucheng.mapper.CategoryMapper;
import com.example.yucheng.domain.Category;
import com.example.yucheng.service.CategoryService;
import com.example.yucheng.util.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    CategoryMapper categoryMapper;


    @Override
    public List<Category> getCategoryByLimit(PageQuery pageQuery) {
        if(pageQuery.getSort()==1){
            return categoryMapper.ascgetCategoryByLimit(pageQuery);
        }else{
            return categoryMapper.getCategoryByLimit(pageQuery);
        }
    }

    @Override
    public int deleteCategorytById(Integer id) {
        return categoryMapper.deleteCategoryById(id);
    }

    @Override
    public List<Category> getAllCategory() {
        return categoryMapper.getAllCategory();
    }

    public String selectCategoryName(String name){
        return categoryMapper.selectCategoryName(name);
    }

    @Override
    public int insertCategory(Category category) {
        return categoryMapper.insertCategory(category);
    }

    @Override
    public int updateCategory(Category category) {
        return categoryMapper.updateCategory(category);
    }
}
